package com.android.infantschool.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.android.infantschool.R;
import com.bumptech.glide.Glide;

/**
 * author cowards
 * created on 2019\3\26 0026
 **/
public class DialogParentsBinding extends Dialog {

    private Activity activity;
    private ImageView imgParentsBinding;
    private String qrCode;

    public DialogParentsBinding(@NonNull Activity context, String qrCode) {
        super(context, R.style.dialog_loading);
        this.activity = context;
        this.qrCode = qrCode;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        setContentView(R.layout.dialog_parents_binding);
        Window window = this.getWindow();
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
        imgParentsBinding = findViewById(R.id.img_parents_binding);
        Glide.with(activity).load(qrCode).into(imgParentsBinding);
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

}